package com.hmall.api.client;

import com.hmall.api.dto.ItemDTO;
import com.hmall.api.dto.OrderDetailDTO;
import com.hmall.api.dto.query.ItemPageQuery;
import com.hmall.common.domain.PageDTO;
import com.hmall.common.domain.PageQuery;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

@FeignClient("item-service")
public interface ItemClient {
    @GetMapping("/items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    @PutMapping("/items/restore")
    void restore(@RequestParam("ids") Collection<Long> ids);

    @PutMapping("/items/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);

    @PostMapping("/items/list")
    public PageDTO<ItemDTO> search(@RequestBody ItemPageQuery query);

    @GetMapping("/items/{id}")
    public ItemDTO queryItemById(@PathVariable("id") Long id);

    @GetMapping("/items/page")
    public PageDTO<ItemDTO> queryItemByPage(PageQuery query);
}
